<template>
	<view>
		<z-nav-bar title="比赛计分">
			<template v-slot:right>
				<button open-type="share">
					<image :src="`${setting.sImgUrl}/share.png`" class="icon-size"></image>
				</button>
			</template>
			<!-- #ifdef MP-WEIXIN -->

			<!-- #endif -->
		</z-nav-bar>
		<view class="result">
			<view class="title">{{ info.title }}</view>
			<view class="time">2023-3-14 10:23-23:12</view>
			<view class="entry">
				<view class="row" v-for="(v, k) in user">
					{{ `${k + 1}号(${v})` }}：
					<text>{{ num[k] }} 杆</text>
				</view>
			</view>
		</view>
		<scroll-view scroll-x>
			<view class="table" v-if="info.hole == '9洞'">
				<view class="tr" v-for="(v, k) in info.result">
					<view class="td" v-for="(vv, kk) in v">
						<text v-if="k > 1 && kk != 0 && kk < 10">{{ vv }}</text>
						<text v-else>{{ vv }}</text>
					</view>
				</view>
			</view>
			<view class="table table2" v-if="info.hole == '18洞'">
				<view class="tr" v-for="(v, k) in info.result">
					<view class="td" v-for="(vv, kk) in v">
						<text v-if="k > 1 && kk > 0 && kk != 10 && kk != 11 && kk < 21">{{ vv }}</text>
						<text v-else>{{ vv }}</text>
					</view>
				</view>
			</view>
		</scroll-view>
		<view style="height: 60rpx"></view>
	</view>
</template>

<script>
import { playDetail } from '@/api/student';
export default {
	data() {
		return {
			id: '',
			info: [],
			num: [],
			user: []
		};
	},
	methods: {
		getInfo() {
			playDetail(this.id).then((res) => {
				this.info = res;
				this.info.result = JSON.parse(res.result);
				this.user = res.names.split(',');
				for (let i in this.info.result) {
					if (res.hole == '9洞' && i > 1) this.num.push(this.info.result[i][12]);
					if (res.hole == '18洞' && i > 1) this.num.push(this.info.result[i][23]);
				}
				console.log(res);
			});
		}
	},
	onShow() {
		// #ifdef MP-WEIXIN
		this.nav = uni.getMenuButtonBoundingClientRect().height;
		// #endif
	},
	onLoad(e) {
		this.id = e.id;
		this.getInfo();
	},
	onShareAppMessage() {
		return {
			title: this.info.title,
			path: '/pages/game/detail?id=' + this.id
		};
	}
};
</script>

<style>
@import './css/detail.css';
button {
	padding-left: 0;
	padding-right: 0;
	line-height: 0;
	background: transparent;
}
button::after {
	border: none;
}
</style>
